home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / mint / utilit~1 / lack.zoo / lack.s < prev    next >
Encoding:
Text File  |  1993-12-22  |  2.9 KB  |  132 lines

  1.         |global:
  2.         .globl  _fs_tbase
  3.         .globl    _trap_2
  4.         .globl  __first_leave_aes
  5.         .globl  __desk_leave_aes
  6.         .globl  _trap_13
  7.         .globl  _trap_3
  8.         .globl  _use_trap_3
  9.         .globl  _spl7
  10.         .globl  _spl
  11.         .globl  __setstack
  12.         |extern:
  13.         .globl _la_init
  14.         .globl _gem        |xbra struct
  15.         .globl _bios
  16.         .globl _mytrap
  17.         .globl _enter_aes
  18.         .globl _leave_aes
  19.         .globl _is_desk
  20.         .globl _os_base
  21.         .text
  22. _fs_tbase:    jmp   _la_init    
  23. _trap_2:    cmpw  #0xc8, d0
  24.         beqs  0f
  25.         movl  _gem+8, sp@-
  26.         rts
  27. 0:        andw  #0xdfff,sp@     |don't return in super
  28.         movml a0-a1, sp@-     |that's right, the aes preserves everything
  29.                                   |but d0
  30.         movl  _curapp, a0
  31.         movl  sp, a1
  32.         movl  a1, a0@
  33.         movl  a0@(4), a0
  34.         movl  a0, sp
  35.         tstw  0x59e           |longframe?
  36.         bnes  0f
  37.         movl  a1@(10),sp@-    |(*pc)()
  38.         bras  1f
  39. 0:        movl  a1@(12), sp@-
  40. 1:        movl  d1, sp@-
  41.         jsr   _enter_aes
  42.         movl  sp@+, d1
  43.         addql #4, sp
  44.         tstw  d0              |did lack manage this one on its own?
  45.         bnes  done
  46.         movw  #0xc8, d0
  47.         pea   pc@(back)       |where trap #2 will return
  48.         tstw  0x59e          |longframe?
  49.         beqs  1f
  50.         clrw  sp@-
  51. 1:        movw  sr, sp@-
  52. call:        movl  _gem+8, sp@-
  53.         rts
  54. back:        tas   _use_trap_3     |the idea is to block anyone elses use of
  55.         trap  #3              |this trap as briefly as possible
  56.         movml d0-d1, sp@-
  57. back_in_super:    jsr   _leave_aes
  58.         movml sp@+, d0-d1
  59. done:        movl  _curapp, a0
  60.         movl  sp, a1
  61.         movl  a1, a0@(4)
  62.         movl  a0@, a0
  63.         movl  a0, sp
  64.         movml sp@+, a0-a1
  65.         rte
  66. __first_leave_aes:
  67.         tas   _use_trap_3
  68.         trap  #3
  69.         tstw  0x59e
  70.         beqs  0f
  71.         subql #2, sp
  72. 0:        subql #6, sp    |now we can rte
  73.         movml d0-d1/a0-a1, sp@-
  74.         jsr   _leave_aes
  75.         tstw  0x59e
  76.         beqs  1f
  77.         movl  d0, sp@(20)
  78.         bra   2f
  79. 1:        movl  d0, sp@(18)
  80. 2:        movml sp@+, d0-d1/a0-a1
  81.         rte        
  82. __desk_leave_aes:        |still in super
  83.         subql #4, sp    |now we can rts
  84.         movml d0-d1/a0-a1, sp@-  |maybe I only need to save d0??
  85.         jsr   _leave_aes
  86.         movl  d0, sp@(16)
  87.         movml sp@+, d0-d1/a0-a1
  88.         rts
  89. _trap_13:
  90.         btst #5, sp@
  91.         beq   not_gem
  92.         tstw  0x59e
  93.         beqs  0f
  94.         movl  sp@(12), d1    |call address
  95.         movl  sp@(8), d0    |func and first arg
  96.         bras  1f
  97. 0:        movl  sp@(10), d1
  98.         movl  sp@(6), d0
  99. 1:        cmpl  #0x50101, d0
  100.         bnes  not_gem
  101.         cmpl  _os_base, d1
  102.         bgts  not_gem
  103. |        cmpl  _os_end, d1
  104. |        blts  not_gem
  105.         movw  #1, _is_desk
  106.         movl  #_gem + 12, 0x88
  107.         movl  d1, 0x404
  108.         rte
  109. not_gem:    movl  _bios+8, sp@-
  110.         rts
  111. _trap_3:    bclr  #7, _use_trap_3
  112.         bnes  good_call
  113.         movl  _mytrap + 8, sp@-
  114.         rts
  115. good_call:    tstw  0x59e
  116.         beqs  1f
  117.         addql #2, sp
  118. 1:        addql #2, sp
  119.         rts
  120. _spl7:        movw  sr,d0
  121.         oriw  #0x700, sr
  122.         rts
  123. _spl:        movw  sp@(4), sr
  124.         rts
  125. |taken directly from crt0.cpp
  126. __setstack:    movel    sp@+, a0    | save return address
  127.         movel    sp@, sp        | new stack pointer
  128.         subql    #4, sp        | fixup for tidy upon return
  129.         jmp    a0@        | back to caller
  130.         .data
  131.         .comm _use_trap_3, 2
  132.